/**
 * @class cceaf.control.YearComboBox
 * @extends Ext.form.ComboBox
 * 
 * 选择月份的下拉框
 */
Ext.define('cceaf.control.MonthComboBox', {
    extend: 'Ext.form.ComboBox',
    requires: [
   	    'cceaf.ControlDefaultConfig'
    ],
    alias: 'widget.cceafmonthcombobox',
    
    constructor: function(config){
		config = config || {};
		
		cceaf.control.MonthComboBox.superclass.constructor.apply(this, arguments);
	},
    
	/**
	 * 开始月份
	 *
     * @property start 
     * @type Number
     * @default 1
     */
	start : 1,
	
	/**
	 * 结束月份
	 *
     * @property end 
     * @type Number
     * @default 12
     */
	end : 12,
	
	initComponent:function(){
		this.initParams();
		
		cceaf.control.MonthComboBox.superclass.initComponent.call(this);
	},
	
	initParams : function(){
		var config = this;
		
		var start,end;
		if(config.start){
			start = config.start;
		}
		
		if(config.end){
			end = config.end;
		}
		
		var ds;
		if(config.store){
			ds = config.store;
		}else{
			ds = new Ext.data.Store({
				fields: ['monthV', 'monthN'],
				data : this.getData(start,end)
			});
		}
		
		var defaultFieldWidth = cceaf.ControlDefaultConfig.DEFAULT_FIELD_WIDTH;
		Ext.applyIf(this, {
			store: ds,
			displayField: 'monthV',
    		valueField: 'monthN',
    		width: defaultFieldWidth
		});
	},
	
	getData: function(start,end){
		var data = [];
		for(var i=start; i<=end; i++){
			data.push({"monthV":i, "monthN":i});
		}
		return data;
	}
	
});

